using System;
using System.Collections.Generic;
using System.Text;

using Presentation.Contracts;
using Task.Contracts;
using Task;
using DataAccess;
using Globals;

namespace Presentation
{
    /// <summary>
    /// Add Forum Presenter.
    /// </summary>
    public sealed class AddForumPresenter
    {
        #region Members

        /// <summary>
        /// Instance of view.
        /// </summary>
        private IAddForumView view;

        /// <summary>
        /// Simple galleryTask.
        /// </summary>
        private IForumTask task;

        #endregion Members

        #region Construction/Finalization

        /// <summary>
        /// Initializes a new instance of the <see cref="AddForumPresenter"/> class.
        /// </summary>
        /// <param name="view">The view.</param>
        public AddForumPresenter(IAddForumView view)
        {
            this.view = view;
            task = new ForumTask();
        }

        #endregion Construction/Finalization

        #region Public Methods

        /// <summary>
        /// Initializes view.
        /// </summary>
        public void Initialize()
        {
            view.ForumDescription = string.Empty;
            view.ForumName = string.Empty;
			view.ShowForums(task.GetOwnedForums(0, Int32.MaxValue, view.LoggedUserID));
			//view.ShowComments(galleryTask.GetComments(3,1,3));
        }

        /// <summary>
        /// Adds the new forum.
        /// </summary>
        public void AddNewForum()
        {
            task.AddForum(GetForumObjectFromView(),view.LoggedUserID);
		}

		public void DeleteMyForum(int forum_id)
			{
			task.DeleteOwnerForum(view.LoggedUserID, forum_id);
			}

        #endregion Public Methods

        #region Private Methods

        /// <summary>
        /// Gets the forum object from view.
        /// </summary>
        /// <returns></returns>
        private forum GetForumObjectFromView()
        {
            forum forumTmp = new forum();
            
            forumTmp.description = view.ForumDescription;
            forumTmp.name = view.ForumName;

            //tmp user id - nie tak, tak nie dziala wlasnie, trzea podac obiekt a nie id obiektu
			//w zasadzie nigdy sie nie dowiedzialem dlaczego... ale tak niestety jest czyli: zobacz w Tasku!
            //forumTmp.user_id = ContentNamesGlobals.TmpUserId;


            return forumTmp;
        }

        #endregion Private Methods
    }
}
